package cn.wolfcode.luowowo.controller;

import cn.wolfcode.luowowo.domain.*;
import cn.wolfcode.luowowo.interceptor.LoginRequire;
import cn.wolfcode.luowowo.redis.srevice.IUserRedisSrevice;
import cn.wolfcode.luowowo.service.IDestinationService;
import cn.wolfcode.luowowo.service.IRegionService;
import cn.wolfcode.luowowo.service.IStrategyCatalogService;
import cn.wolfcode.luowowo.service.IUserInfoService;
import cn.wolfcode.luowowo.service.impl.StrategyServiceImpl;
import cn.wolfcode.luowowo.service.impl.TravelServiceImpl;
import cn.wolfcode.luowowo.util.JsonResult;
import com.alibaba.fastjson.JSON;
import com.sun.org.apache.regexp.internal.RE;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;


@RestController
@RequestMapping("destinations")
public class DestinationController {
    @Autowired
    private IDestinationService destinationService;
    @Autowired
    private IRegionService regionService;
    @Autowired
    private IStrategyCatalogService strategyCatalogService;
    //攻略分类
    @Autowired
    private StrategyServiceImpl strategyService;
    @Autowired
    private TravelServiceImpl travelService;
    //查询热门区域
    @GetMapping("/hotRegion")
    public Object hotRegion() {
        /*查询全部 不需要传输参数*/
        List<Region> regions = regionService.queryHotRegion();
        return JsonResult.success(regions);
    }
    
    
    @GetMapping("/search")
    /*regionId 区域id  通过传过来的区域id来得到关联目的地的list集合*/
    public Object search(String regionId) {
        List<Destination> dest = destinationService.getDestByRegionIdForApi(regionId);
        return JsonResult.success(dest);
    }
    
    /**
     * 吐司操作
     *
     * @return
     */
    @GetMapping("/toasts")
    public Object toasts(String destId) {
        return JsonResult.success(destinationService.getToasts(destId));
    }
    
    /**
     * 概况目的地下的所有攻略和分类
     */
    @GetMapping("/catalogs")
    public Object detail(String destId){
        //先用目的地查分类 然后获取里面的攻略
        List<StrategyCatalog> list = strategyCatalogService.selectCatalogByDestId(destId);
        return JsonResult.success(list);
    }
    /**
     * 目的地下面点击量排名前三的攻略
     */
    @GetMapping("/strategies/viewnumTop3")
    public  Object strategiesViewnumTop3(String destId){
        List<Strategy> strategies = strategyService.selectViewnumTop3(destId);
        return JsonResult.success(strategies);
    }
    
    /**
     * 目的地下面点击量排名前三的攻略
     */
    @GetMapping("/travels/viewnumTop3")
    public  Object travelsViewnumTop3(String destId){
        List<Travel> travels = travelService.selectViewnumTop3(destId);
        return JsonResult.success(travels);
    }
/*    @GetMapping("/detail")
    public Object detail(){
        
        return JsonResult.success();
    }*/
}
